package cn.itcasa.itemlistener;

import cn.itcasa.mqconstants.MqConstants;
import cn.itcasa.service.SearchService;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

@Component
public class ItemListener {
    @Autowired
    private SearchService searchService;

    @RabbitListener(queues = MqConstants.ITEM_INSERT_QUEUE)
    public void ListenerItemInsterOrUpdate(Long id) {
        searchService.insterItemById(id);
    }

    @RabbitListener(queues = MqConstants.ITEM_DELETE_QUEUE)
    public void ListenerItemDelete(Long id) {

        searchService.deleteItemById(id);
    }
}
